var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2AudioManager = require("AudioManager");
var $2BulletMgr = require("BulletMgr");
var $2DataManager = require("DataManager");
var $2ZombieMgr = require("ZombieMgr");
var $2KDefine = require("KDefine");
var $2BulletBase = require("BulletBase");
var $2TombStone = require("TombStone");
var $2PlantBase = require("PlantBase");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_Plant8 = /* */function (_h$default3) {
  babel_inherits(p, _h$default3);
  var _super70 = babel_createSuper(p);
  function p() {
    babel_classCallCheck(this, p);
    return _super70.apply(this, arguments);
  }
  babel_createClass(p, [{
    key: "shoot",
    value: function shoot() {
      var _this152 = this;
      var e = this;
      if (0 == this.remainCD) {
        var _t49 = this.dragon.setAnimation(0, "dazhao", true);
        var _a39 = 0;
        this.dragon.setCompleteListener(function () {
          if (++_a39 == _this152.skillNums) {
            e.setState($2KDefine.State.wait);
            _this152.attackTimes += _this152.attackCD;
            _this152.remainCD = _this152.skillCD;
          }
        });
        this.dragon.setTrackEventListener(_t49, function (e, t) {
          "dazhao" == t.data.name && _this152.attack(true);
        });
      } else {
        var _t50 = this.dragon.setAnimation(0, "gongji", false);
        this.dragon.setCompleteListener(function () {
          e.setState($2KDefine.State.wait);
        });
        this.attackTimes += this.attackCD;
        this.dragon.setTrackEventListener(_t50, function (e, t) {
          "gongji" == t.data.name && _this152.attack();
        });
      }
    }
  }, {
    key: "attack",
    value: function attack() {
      var _this153 = this;
      var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      var t;
      if (e) {
        t = $2BulletMgr.default.instance().getItem(this.skillbullet, this.damage, this.hitSound, this.hitSoundVolume).node;
        $2AudioManager.default.instance.playEffect(this.skillSound, this.skillSoundVolume);
      } else {
        t = $2BulletMgr.default.instance().getItem(this.bulletId, this.damage, this.hitSound, this.hitSoundVolume).node;
        $2AudioManager.default.instance.playEffect(this.shootSound, this.shootSoundVolume);
      }
      t.parent = this.node;
      t.setPosition(this.shootPo);
      t.zIndex = $2KDefine.ZIndex.bullet;
      t.getComponent(cc.CircleCollider).enabled = false;
      t.anchorX = 0;
      cc.tween(t).call(function () {
        t.opacity = 255;
      }).to(.05, {
        width: 3e3
      }).call(function () {
        var e = $2ZombieMgr.default.instance().zombieInRow[_this153.row].values();
        var a = e.next();
        for (var _n38 = 0; _n38 < $2DataManager.default.instance.col; _n38++) {
          $2DataManager.default.instance.blockArr[_this153.row][_n38][1] && $2DataManager.default.instance.blockArr[_this153.row][_n38][1].getComponent($2TombStone.default) && $2DataManager.default.instance.blockArr[_this153.row][_n38][1].x > _this153.node.x && $2DataManager.default.instance.blockArr[_this153.row][_n38][1].x - _this153.node.x < $2DataManager.default.instance.blockWidth * (_this153.attDistance + .5) && $2DataManager.default.instance.blockArr[_this153.row][_n38][1].getComponent($2TombStone.default).hurt(_this153.damage, t.getComponent($2BulletBase.default).bulletEffect, t.getComponent($2BulletBase.default).effectScale);
        }
        for (; !a.done;) {
          var _n39 = a.value;
          if (_n39.hp > 0 && _n39.node.x - _this153.node.x > 0) {
            if (16 == _n39.id) {
              _n39.hurt(_this153.damage, t.getComponent($2BulletBase.default).bulletEffect, t.getComponent($2BulletBase.default).effectScale, 0, 0, true);
            } else {
              _n39.hurt(_this153.damage, t.getComponent($2BulletBase.default).bulletEffect, t.getComponent($2BulletBase.default).effectScale);
            }
          }
          a = e.next();
        }
      }).delay(.1).to(.05, {
        width: 0
      }).call(function () {
        t.width = 38;
        t.getComponent(cc.CircleCollider).enabled = true;
        t.anchorX = .5;
        $2BulletMgr.default.instance().removeBullet(t.getComponent($2BulletBase.default));
      }).start();
    }
  }]);
  return p;
}($2PlantBase.default);
def_Plant8 = cc__decorate([ccp_ccclass], def_Plant8);
exports.default = def_Plant8;